import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:get_it/get_it.dart';
import 'package:yuque/app_theme.dart';
import 'package:yuque/navigation_home_screen.dart';
import 'package:yuque/page/pages.dart';
import 'package:yuque/routes.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  GetIt.I.allowReassignment = true;
  runApp(YuQue());
}

class YuQue extends StatelessWidget {
  final GlobalKey<NavigatorState>? navKey = GlobalKey();

  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark);
    return MaterialApp(
      navigatorKey: navKey,
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.green,
        textTheme: AppTheme.textTheme,
        scaffoldBackgroundColor: Color(0xFFF5F5F5),
        scrollbarTheme: ScrollbarThemeData(
          isAlwaysShown: true,
          thumbColor: MaterialStateProperty.all<Color>(Colors.black),
        ),
        platform: TargetPlatform.iOS,
      ),
      initialRoute: Routes.home,
      onGenerateRoute: (RouteSettings settings) {
        return Routes.pageRoute(settings, (context) {
          switch (settings.name) {
            case Routes.home:
              return const NavigationHomeScreen();
            case Routes.post:
              return const PostPage();
            default:
              return const SizedBox.shrink();
          }
        });
      },
    );
  }
}
